﻿using System;
using System.Collections.Generic;

namespace Meqs.Entity.Views
{
    [Serializable]
    public class AnswerEntity
    {
        private int _questionItemID;
        private int _qiType;
        private double _avgScore;
        private double _avgPercent;
        private double _maxScore;
        private int _replyNum;
        private IList<string> _replyEntities;

        public AnswerEntity()
        {
        }

        public AnswerEntity(int questionItemID, int qiType, double avgScore, double avgPercent, double maxScore, int replyNum, IList<string> replyEntities)
        {
            _questionItemID = questionItemID;
            _qiType = qiType;
            _avgScore = avgScore;
            _avgPercent = avgPercent;
            _maxScore = maxScore;
            _replyNum = replyNum;
            _replyEntities = replyEntities;
        }

        public int QuestionItemID
        {
            get { return _questionItemID; }
            set { _questionItemID = value; }
        }

        public int QiType
        {
            get { return _qiType; }
            set { _qiType = value; }
        }

        public double AvgPercent
        {
            get { return _avgPercent; }
            set { _avgPercent = value; }
        }

        public double AvgScore
        {
            get { return _avgScore; }
            set { _avgScore = value; }
        }

        public double MaxScore
        {
            get { return _maxScore; }
            set { _maxScore = value; }
        }

        public int ReplyNum
        {
            get { return _replyNum; }
            set { _replyNum = value; }
        }

        public IList<string> ReplyEntities
        {
            get { return _replyEntities; }
            set { _replyEntities = value; }
        }

        public bool Equals(AnswerEntity other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._questionItemID == _questionItemID;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (AnswerEntity)) return false;
            return Equals((AnswerEntity) obj);
        }

        public override int GetHashCode()
        {
            return _questionItemID;
        }
    }

    public class AnswerEntityExtend : AnswerEntity
    {
        private double _avgClsScore;

        public AnswerEntityExtend()
        {
        }

        public AnswerEntityExtend(int questionItemID, int qiType, double avgScore, double avgPercent, double maxScore, int replyNum, IList<string> replyEntities, double avgClsScore) : base(questionItemID, qiType, avgScore, avgPercent, maxScore, replyNum, replyEntities)
        {
            _avgClsScore = avgClsScore;
        }

        /// <summary>
        /// 班级平均分
        /// </summary>
        public double AvgClsScore
        {
            get { return _avgClsScore; }
            set { _avgClsScore = value; }
        }

        /// <summary>
        /// 均差
        /// </summary>
        public double AvgMinuteClsScore
        {
            get { return AvgScore - _avgClsScore; }
        }
    }
}
